package com.cosmos.codegen.base.facade;

/**
 * 入口详细
 * 
 * @date 2016-3-22 10:02:24
 * @version 1.0
 * @author zhuzhaoyong
 *
 */
import com.cosmos.codegen.base.domain.DBType;
import com.cosmos.codegen.base.engine.FreeMarkerEngine;
import com.cosmos.codegen.base.engine.MySQLFreeMarkerEngine;
import com.cosmos.codegen.base.engine.ORACLEFreeMarikerEngine;

public class GenerateEntityFacade {

	private String projectRoot;
	
	private String dist;
	
	private String dbType;
	
	private String[] tablesName;
	
	private String prefix;

	public void setProjectRoot(String projectRoot) {
		this.projectRoot = projectRoot;
	}

	public void setDist(String dist) {
		this.dist = dist;
	}

	public void setDbType(String dbType) {
		this.dbType = dbType;
	}

	public void setTablesName(String[] tablesName) {
		this.tablesName = tablesName;
	}
	
	public void setPrefix(String prefix) {
		this.prefix = prefix;
	}
	
	public FreeMarkerEngine getFreeMarkerEngine(String dbType) {
		if(null == dbType || "".equals(dbType) || DBType.MYSQL.getValue().equalsIgnoreCase(dbType)) {
			return new MySQLFreeMarkerEngine();
		} else if(DBType.ORACLE.getValue().equalsIgnoreCase(dbType)) {
			return new ORACLEFreeMarikerEngine();
		}
		return null;
	}

	public void exec() {
		FreeMarkerEngine freeMarkerEngine = getFreeMarkerEngine(dbType);
		freeMarkerEngine.exec(projectRoot, dist, tablesName, prefix);
	}
}
